Sum

edited May 2016 in FastReport .NET
I am using FastReport VB.Net. I have created a simple report with several columns: Beginning Depreciation, Depreciation, and Ending Depreciation.
I want to have the total of Beginning Depreciation plus Depreciation appear in the column labeled Ending Depreciation for each row. See the PDF attachment.

I have been able to get a total for each column and show it in the bottom of the report. But I also want to do a simple adding of two of the column rows and enter it in the Ending Depreciation column.

And I don't know how to do that. This is something that should be real simple. I can do it with the ReportViewer like: sum([Beginning_Depreciation] + [Depreciation]). How is it done in Fast Reports?

I have right clicked on the Summation symbol and tried to enter sum([Beginning_Depreciation] + [Depreciation]), but I get an error message that Sum is not recognized.

What am I doing wrong? How is it supposed to be entered?

Comments

  • edited 3:27AM
    BobV365 wrote: »
    I am using FastReport VB.Net. I have created a simple report with several columns: Beginning Depreciation, Depreciation, and Ending Depreciation.
    I want to have the total of Beginning Depreciation plus Depreciation appear in the column labeled Ending Depreciation for each row. See the PDF attachment.

    I have been able to get a total for each column and show it in the bottom of the report. But I also want to do a simple adding of two of the column rows and enter it in the Ending Depreciation column.

    And I don't know how to do that. This is something that should be real simple. I can do it with the ReportViewer like: sum([Beginning_Depreciation] + [Depreciation]). How is it done in Fast Reports?

    I have right clicked on the Summation symbol and tried to enter sum([Beginning_Depreciation] + [Depreciation]), but I get an error message that Sum is not recognized.

    What am I doing wrong? How is it supposed to be entered?


    use reportscript :
    public class ReportScript
      {
        private decimal runTotal;
        
        private void Data1_BeforePrint(object sender, EventArgs e)
        {
          runTotal += (Decimal)Report.GetColumnValue("MainReport.Beginning") +  (Decimal)Report.GetColumnValue("MainReport.Ending");
        }
      }
    

    and at reportsummary band, put textobject with expression [runTotal]
  • edited May 2016
    Thank you for your reply, but what I am trying to do is get the sum of two fields that are on the report and entering the summation in a field called Ending.

    For example, there is a field called Beginning and another called Depreciation. I want to add the value of the field called Beginning to the value of the field called Depreciation and enter the total in a third field called Ending.

    I do not want to add two column totals together. I want to add two individual fields together. This needs to be done for each row of the table. What would the code syntax for adding the two fields together and then putting the value in the field called Ending?

    Any help with the code to accomplish this task will be greatly appreciated. Thank you so much.
  • edited 3:27AM
    In 'ending' textobject, try this expression : Beginning_Depreciation] + [Depreciation
  • edited 3:27AM
    ipong wrote: »
    In 'ending' textobject, try this expression : Beginning_Depreciation] + [Depreciation

    I entered your suggested formula in the Ending TextObject and I get an error that says Error CS1525: Invalid expression term '

    I am puzzled as to why it is so hard for me to find a reference in the Fast Report manual and on this forum board for the proper syntax to add together the values of two textobjects in the data band. It is very easy to do in Report Viewer. In Report Viewer the formula is simply:

    =Sum(Field!Beginning.Value + Fields!Depreciation.Value)

    Isn't there something similar to the Report Viewer formula above that can be entered in the Data Band of a Fast Report to do the same thing?

    Any help with the syntax of a simple SUM function that can be entered in the Data Band of a Fast Report would be greatly appreciated.

    Thanks
  • edited May 2016
    There is no problem with syntax Beginning_Depreciation] + [Depreciation

    Beware with datasource, if your data source is MainReport then it should be : MainReport.Beginning_Depreciation] + [MainReport.Depreciation

    I think you miss 'datasource dot'

    Please attach your frx file, easier to find out the problem.
  • edited May 2016
    ipong wrote: »
    There is no problem with syntax Beginning_Depreciation] + [Depreciation

    Beware with datasource, if your data source is MainReport then it should be : MainReport.Beginning_Depreciation] + [MainReport.Depreciation

    I think you miss 'datasource dot'

    Please attach your frx file, easier to find out the problem.

    Thank you ipong,

    The syntax that you suggested worked! >Beginning_Depreciation] + [Depreciation

    I entered it as text in a blank TextBox, and it worked just like I wanted it to. The trick was the extra brackets that enclosed the entire expression.

    I was making the mistake of creating a New Total object and then entering the expression Beginning_Depreciation] + [Depreciation and I kept getting an error. I should have used a Textbox to enter the expression. I was also thinking that I needed the word SUM in the expression.

    Thanks again,
    BobV365

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.